package Year22_Month03.day14;

import java.util.Scanner;

public class Main2 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s1 = sc.nextLine();
        String s2 = sc.nextLine();
        System.out.println(fun(s1,s2));
    }

    public static String fun(String s1,String s2){
        if(s1 == null || s2 == null){
            return null;
        }
        String max = null;
        String min = null;
        //首先我要确定最长字符串和最短字符串，因为我要最短字符串来进行匹配
        if(s1.length() > s2.length()){
            max = s1;
            min = s2;
        }else{
            max = s2;
            min = s1;
        }
        //这里外围循环确定长度，每一个长度都尝试一次，从大到小，一旦有合适的，立马就返回就好
        for (int i = 0; i < min.length(); i++) {
            //内层循环用来比价
            for(int begin = 0, end = min.length() - i;end < min.length();begin++,end++){
                String s = min.substring(begin,end);
                if(max.contains(s)){
                    return s;
                }
            }
        }
        return null;
    }
}
